package com.orkasgb.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.orkasgb.common.CommonResult;
import com.orkasgb.entity.OrkasgbTaskDetailsEntity;
import com.orkasgb.service.IOrkasgbTaskDetailsService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.List;

/**
 * 任务信息表(TOrkasgbTaskDetails)表控制层
 *
 * @version 1.0.0
 * @since 2024-09-08 21:17:23
 */
@RestController
@RequestMapping("orkasgbTaskDetails")
public class OrkasgbTaskDetailsController {
	
	/**
	 * 服务对象
	 */
	@Resource
	private IOrkasgbTaskDetailsService orkasgbTaskDetailsService;
	
	/**
	 * 通过主键查询单条数据
	 *
	 * @param id 主键
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbTaskDetails/{id}")
	public CommonResult<OrkasgbTaskDetailsEntity> getOrkasgbTaskDetails (@PathVariable("id") Serializable id) {
		return CommonResult.ofSuccess(orkasgbTaskDetailsService.getOrkasgbTaskDetails(id));
	}
	
	/**
	 * 通过条件查询多条数据
	 *
	 * @param orkasgbTaskDetails 实体查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbTaskDetailsList")
	public CommonResult<List<OrkasgbTaskDetailsEntity>> getOrkasgbTaskDetailsList (@RequestBody OrkasgbTaskDetailsEntity orkasgbTaskDetails) {
		return CommonResult.ofSuccess(orkasgbTaskDetailsService.getOrkasgbTaskDetailsList(orkasgbTaskDetails));
	}
	
	/**
	 * 通过条件查询多条数据(分页查询)
	 *
	 * @param orkasgbTaskDetails 查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbTaskDetailsPageDataList")
	public CommonResult<IPage<OrkasgbTaskDetailsEntity>> getOrkasgbTaskDetailsPageDataList (@RequestBody OrkasgbTaskDetailsEntity orkasgbTaskDetails) {
		return CommonResult.ofSuccess(new Page<OrkasgbTaskDetailsEntity>().setRecords(orkasgbTaskDetailsService.getOrkasgbTaskDetailsPageDataList(orkasgbTaskDetails)));
	}
	
	/**
	 * 新增数据
	 *
	 * @param orkasgbTaskDetails 实体对象
	 * @return 新增结果
	 */
	@PostMapping("addOrkasgbTaskDetails")
	public CommonResult<Integer> addOrkasgbTaskDetails (@RequestBody OrkasgbTaskDetailsEntity orkasgbTaskDetails) {
		return CommonResult.ofSuccess(orkasgbTaskDetailsService.addOrkasgbTaskDetails(orkasgbTaskDetails));
	}
	
	/**
	 * 修改数据
	 *
	 * @param orkasgbTaskDetails 实体对象
	 * @return 修改结果
	 */
	@PutMapping("updateOrkasgbTaskDetails")
	public CommonResult<Integer> updateOrkasgbTaskDetails (@RequestBody OrkasgbTaskDetailsEntity orkasgbTaskDetails) {
		return CommonResult.ofSuccess(orkasgbTaskDetailsService.updateOrkasgbTaskDetails(orkasgbTaskDetails));
	}
	
	/**
	 * 修改或者新增数据
	 *
	 * @param orkasgbTaskDetailsList 实体对象
	 * @return 操作结果
	 */
	@PostMapping("addOrUpdateOrkasgbTaskDetails")
	public CommonResult<Integer> addOrUpdateOrkasgbTaskDetails (@RequestBody List<OrkasgbTaskDetailsEntity> orkasgbTaskDetailsList) {
		return CommonResult.ofSuccess(orkasgbTaskDetailsService.addOrUpdateOrkasgbTaskDetails(orkasgbTaskDetailsList));
	}
	
	/**
	 * 删除数据
	 *
	 * @param idList 主键结合
	 * @return 删除结果
	 */
	@DeleteMapping("deleteOrkasgbTaskDetailsByIds")
	public CommonResult<Integer> deleteOrkasgbTaskDetailsByIds (@RequestParam("idList") List<Long> idList) {
		return CommonResult.ofSuccess(orkasgbTaskDetailsService.deleteOrkasgbTaskDetailsByIds(idList));
	}
	
}

